﻿using System;
using System.Threading;
using System.Windows.Forms;

using GECS.Core;

namespace GECS.Audio{
	
	/// <summary>
	/// Represents a Sound. Supports MP3, WAV and AIFF audio. MIDI isn't supported.
	/// </summary>
	public abstract class Sound {
		
		/// <summary>
		/// Plays the Sound
		/// </summary>
		public virtual void Play(){}
		
		/// <summary>
		/// Stops the Sound
		/// </summary>
		public virtual void Stop(){}
		
		/// <summary>
		/// Gets or sets the looping value on this sound
		/// </summary>
		public bool Loop { get; set; }
		
		/// <summary>
		/// Returns True if Playing. Else False.
		/// </summary>
		public bool IsPlaying { get; set; }
			
		/// <summary>
		/// Loads a sound from the embedded Resource
		/// </summary>
		/// <param name="name">The name of the resource</param>
		/// <returns>Loaded sound</returns>
		public static Sound LoadSound(string name)
		{
			string ext = System.IO.Path.GetExtension(name).ToLower();
			if (WavSound.IsSupported(ext))
			{
				// Create a WavSound
				return (Sound) new WavSound(name, ext);
			}
			// Unsupported format
			MessageBox.Show("Unsupported format : " + ext);
			return null;
		}
		
		
	}
	
}